package me.zk.practice1.hw;

import java.util.Arrays;
import java.util.Scanner;

/**
 * @author zhangkai
 * @date 2023/8/10 16:19
 */
public class HWBJJ27_2 {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int[] nums = Arrays.stream(scanner.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();

        if (nums.length==1) {
            System.out.println(nums[0]);
            return;
        } else if (nums.length == 2) {
            System.out.println(Math.max(nums[0],nums[1]));
            return;
        }
        System.out.println(Math.max(get(nums,0,nums.length),get(nums,1,nums.length-1)));
    }

    public static int get(int[] nums, int start, int end) {

        int a = nums[start];
        int b = nums[start+1];

        for (int i = start+2; i<end ; i++) {
            int temp = b;
            b = Math.max(a + nums[i],b);
            a = temp;

        }
        return a;

    }
}
